package com.learn.eduadboot.controller;

import com.learn.eduadboot.service.PromotionAdService;
import com.learn.eduapi.entity.ResponseDTO;
import com.learn.eduapi.entity.ad.PromotionAd;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 新闻微服务8001
 */
@RestController
@CrossOrigin
@RequestMapping("ad")
public class AdController {
    @Autowired
    private PromotionAdService promotionAdService;
    /**
     * 通过广告位查询广告列表
     * @param sid
     * @return
     */
    @GetMapping("/getAdsBySpaceId/{spaceid}")
    public ResponseDTO<List<PromotionAd>> getAdsBySpaceId(@PathVariable("spaceid") Integer sid){
        List<PromotionAd> list = promotionAdService.getAdsBySpaceId(sid);
        ResponseDTO<List<PromotionAd>> responseDTO = new ResponseDTO<>();
        responseDTO.setContent(list);
        responseDTO.setMessage("广告轮播图获取成功");
        responseDTO.setState(200);
        return responseDTO;
    }

}
